package cn.example.demo.vo;

import cn.example.demo.exception.ResultCode;
import lombok.Getter;

/**
 * @ProjectName: springbootmybatisinvoicings
 * @Package: cn.example.demo.vo
 * @ClassName: ResultVO
 * @Author: liang
 * @Description: 统一返回数据
 * @Date: 2020/4/11 11:20
 * @Version: 1.0
 */
@Getter
public class ResultVO<T> {
    /**
     * 状态码，比如1000代表响应成功
     */
    private int code;
    /**
     * 响应信息，用来说明响应情况
     */
    private String msg;
    /**
     * 响应的具体数据
     */
    private T data;

    public ResultVO(T data) {
        this(ResultCode.SUCCESS,  data);
    }

    public ResultVO(ResultCode resultCode, T data) {
        this.code = resultCode.getCode();
        this.msg = resultCode.getMsg();
        this.data = data;
    }
    public ResultVO(ResultCode resultCode){
        this.code = resultCode.getCode();
        this.msg = resultCode.getMsg();
    }
}
